home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Games / Arashi 1.1 / Game Source / mtz / mtz src / STFloatingScores.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-17  |  1.9 KB  |  100 lines  |  [TEXT/KAHL]

  1. /* This file takes care of the floating scores above Fuseballs                     */
  2. /* It basically implememts another set of 7 segment #'s, like VADrawNumber         */
  3. /* but it is compatible with using on the pplaying field, VADrawNumber will     */
  4. /* overdraw the playing field and leave holes when erased. (mz)                    */
  5.  
  6. /* December 22,1992 © Mike Zimmerman */
  7.  
  8.  
  9. #include "VA.h"
  10. #include "Storm.h"
  11. #include <Math.h>
  12.  
  13. #define STARTAGE         40
  14. #define    MAXFLSCORES        20
  15.  
  16. extern    Player    Hero;
  17.  
  18. typedef struct
  19. {
  20.     int        AGE;
  21.     int        score;
  22.     int        x1;
  23.     int        y1;
  24.     int        scale;
  25. }    FloatingScore;
  26.  
  27. int    FSCount;
  28. int FSStart;
  29. FloatingScore    *FLScores;
  30.  
  31.  
  32. void    DrawScore(x,y,score,scale)
  33. int    x;
  34. int    y;
  35. int    score;
  36. int    scale;
  37. {
  38.     int        numlen;
  39.     
  40.     VA.color=BG1;                        
  41.     VA.segmscale=scale;
  42.     VADrawNumber(score,x,y);
  43. }
  44.  
  45. void UpdateFloatingScores()
  46. {
  47.     int    i,j;
  48.  
  49.     for(i = FSStart;i < ((FSCount+FSStart)%MAXFLSCORES) ; i++)
  50.     {
  51.         j=i%MAXFLSCORES;
  52.         FLScores[j].AGE -= 1;
  53.         if (FLScores[j].AGE == 0 || Hero.state == HeroFlying) 
  54.         /* Score expired, so remove it */
  55.         {
  56.             VA.color=-1;                        
  57.             VA.segmscale=FLScores[j].scale;
  58.             VADrawNumber(FLScores[j].score,FLScores[j].x1,FLScores[j].y1);
  59.             FLScores[j].AGE = 0;
  60.             FSCount--;
  61.             FSStart++;
  62.             VA.color=0;
  63.             if (FSCount == 0)
  64.                 RedrawField();
  65.         }
  66.     }
  67. }
  68.  
  69. void    AddFLScore(x,y,fscore)  /* mz */
  70. int    x;
  71. int    y;
  72. int    fscore;
  73. {
  74.     FLScores[(FSCount+FSStart)%MAXFLSCORES].scale = (int)(Getfontscale());
  75.     DrawScore(x,y,fscore,FLScores[(FSCount+FSStart)%MAXFLSCORES].scale);
  76.     FLScores[(FSCount+FSStart)%MAXFLSCORES].AGE=STARTAGE;
  77.     FLScores[(FSCount+FSStart)%MAXFLSCORES].score=fscore;
  78.     FLScores[(FSCount+FSStart)%MAXFLSCORES].x1=x;
  79.     FLScores[(FSCount+FSStart)%MAXFLSCORES].y1=y;
  80.     FLScores[(FSCount+FSStart)%MAXFLSCORES].scale = (int)(Getfontscale());
  81.     FSCount++;
  82. }
  83.  
  84. void    AllocFloatingScores()
  85. {
  86.     FLScores=(FloatingScore *)NewPtr(sizeof(FloatingScore) * MAXFLSCORES);
  87.     FSCount=0;
  88. }
  89.  
  90. void    InitFloatingScores()
  91. {
  92.     register    int        i;
  93.     
  94.     for(i=0;i<MAXFLSCORES;i++)
  95.     {    FLScores[i].AGE=0;
  96.     }
  97.     FSCount=0;
  98.     FSStart=0;
  99. }
  100.